#include<iostream>
#include<math.h>
using namespace std;
int return_number(char c)
{
    int num;
    switch (c)
    {
    case ')':num = 0; break;
    case '!':num = 1; break;
    case '@':num = 2; break;
    case '#':num = 3; break;
    case '$':num = 4; break;
    case '%':num = 5; break;
    case '^':num = 6; break;
    case '&':num = 7; break;
    case '*':num = 8; break;
    case '(':num = 9; break;
    }
    return num;
}
char C1(int num)
{
    char c;
    switch (num)
    {
    case 0:c = ')'; break;
    case 1:c= '!'; break;
    case 2:c = '@'; break;
    case 3:c = '#'; break;
    case 4:c = '$'; break;
    case 5:c = '%'; break;
    case 6:c = '^'; break;
    case 7:c = '&'; break;
    case 8:c = '*'; break;
    case 9:c = '('; break;
    }
    return c;
}
string return_s(int num)
{
    string s="";
    bool flag;
    if (num < 0)
    {
        flag = 1;
    }
    else
    {
        flag = 0;
    }
    while (abs(num) > 0)
    {
        //cout << num - 10*((int)num / 10);
        s = C1((num - 10 * ((int)num / 10))) + s;
        num /= 10;
    }
    if (flag)
    {
        s = '-' + s;
        return s;
    }
    else
    {
        return s;
    }
    
}
int ston(string s)
{
    int r = 1;
    int result = 0;
    int xishu = 0;
    for (int i = s.size() - 1; i > -1; i--)
    {
        //cout << return_number(s[i]) << " " << pow(10, xishu)<<endl;
        if (s[i] == '-')
        {
            return result * (-1);
        }
        result+=return_number(s[i])* pow(10, xishu);
        xishu++;
    }
    return result;
}
int main()
{
    string s1, s2;
    
    //cout<< ston(s1);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s1 >> s2;
        cout << return_s(ston(s1)+ ston(s2)) << endl;
        cout << return_s(ston(s1) - ston(s2)) << endl;
        cout << return_s(ston(s2) - ston(s1)) << endl;
    }
    
}